﻿using System.Collections.Generic;
using System.Threading.Tasks;

namespace Jiffy.Core.Auth.Remote
{
    public interface ISysCacheService
    {
        /// <summary>
        /// 增加缓存Key
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <returns></returns>
        Task AddCacheKey(string cacheKey);

        /// <summary>
        /// 删除某特征关键字缓存
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        Task DelByPatternAsync(string key);

        /// <summary>
        /// 删除某个key下的缓存
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <returns></returns>
        Task DelCacheKey(string cacheKey);

        /// <summary>
        /// 检查给定 key 是否存在
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <returns></returns>
        bool Exists(string cacheKey);

        /// <summary>
        /// 获取所有缓存关键字
        /// </summary>
        /// <returns></returns>
        Task<List<string>> GetAllCacheKeys();

        /// <summary>
        /// 获取缓存
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="cacheKey"></param>
        /// <returns></returns>
        Task<T> GetAsync<T>(string cacheKey);

        /// <summary>
        /// 增加缓存Key
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <returns></returns>
        Task<string> GetStringAsync(string cacheKey);

        /// <summary>
        /// 删除指定关键字缓存
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        Task RemoveAsync(string key);

        /// <summary>
        /// 设置缓存<c>[保存对象]</c>
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        Task SetAsync(string cacheKey, object value);

        /// <summary>
        /// 设置缓存<c>[保存字符串]</c>
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        Task SetStringAsync(string cacheKey, string value);
    }
}
